/*
 *   Copyright (c) 2010 Sonrisa Informatikai Kft. All Rights Reserved.
 * 
 *  This software is the confidential and proprietary information of
 *  Sonrisa Informatikai Kft. ("Confidential Information").
 *  You shall not disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Sonrisa.
 * 
 *  SONRISA MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 *  THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 *  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 *  PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SONRISA SHALL NOT BE LIABLE FOR
 *  ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 *  DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

package com.zh.jbet.web.components.datatable;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.markup.html.repeater.data.table.filter.FilterForm;
import org.apache.wicket.extensions.markup.html.repeater.data.table.filter.TextFilteredPropertyColumn;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

/**
 *
 * @author sonrisa
 */
public class K11TextFilteredPropertyColumn<T, F> extends TextFilteredPropertyColumn<T, F>{

    private IModel<String> tooltipModel;
    private String cssClass;

    public K11TextFilteredPropertyColumn(IModel<String> displayModel, String sortProperty,
		String propertyExpression, boolean wordBreak) {
        super(displayModel, sortProperty, propertyExpression);
        cssClass = wordBreak ? "wordbreak " + propertyExpression + "Col" : propertyExpression + "Col";
    }

    public IModel<String> getTooltipModel() {
        return tooltipModel;
    }

    public void setTooltipModel(IModel<String> tooltipModel) {
        this.tooltipModel = tooltipModel;
    }

    @Override
    public String getCssClass() {
        return cssClass;
    }
    
    @Override
    public Component getFilter(String componentId, FilterForm form) {
        Component filter = super.getFilter(componentId, form);
        String clz = getPropertyExpression() + "Input";
        filter.add(new AttributeAppender("class", new Model<String>(clz), " "));
        if (tooltipModel != null) {
            filter.add(new AttributeModifier("title", true, tooltipModel));
        }
        return filter;
    }
}
